package lambda05;

import org.junit.Test;

import java.util.function.Consumer;

/**
 * Java中已经定义的函数式接口:Consumer
 *  一般用于只传递参数(用来消费),而不获取结 果的操作
 *
 * @FunctionalInterface
 * public interface Consumer<T> {
 *     void accept(T t);
 * }
 */
public class ConsumeDemo {
    @Test
    public void test01(){
        Consumer<String> c = (String str)->{
            System.out.println(str);
        };//Consumer<String> c = new ConsumerDemo$$Lambda01();
        c.accept("abc");
    }

    @Test
    public void test02(){
        Consumer<String> c = str -> System.out.println(str);
        c.accept("你好");
    }

    @Test
    public void test03(){
        Consumer<String> c = str -> System.out.println(str.length());
        c.accept("abc");
    }
}
/**
 class ConsumerDemo$$Lambda01 implements Consumer<String>{
    public void accept(String t){
        System.out.println(t);
    }
 }
 */